package com.uniapp.java.uniappjava.controller;

import com.uniapp.java.uniappjava.pojo.User;
import com.uniapp.java.uniappjava.service.UserService;
import com.uniapp.java.uniappjava.utils.Result;
import com.uniapp.java.uniappjava.utils.UUIDUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lsy_server
 */
@RestController
@RequestMapping("user")
@Api(value = "用户")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping
    @ApiOperation(value = "注册新用户", notes = "注册新用户", produces = "application/json")
    public Result add(@RequestBody User user) {
        user.setId(UUIDUtils.getId());
        userService.save(user);
        return Result.ok(user);
    }


}
